#pragma once
#include "Protocol.hpp"
#include <iostream>

class Caculate
{

public:
    Caculate() = default;
    ~Caculate() = default;
    Response Excute(const Request &request)
    {
        int result = 0;
        switch (request.Oper())
        {
        case '+':
            result = request.X() + request.Y();
            break;
        case '-':
            result = request.X() - request.Y();
            break;
        case '*':
            result = request.X() * request.Y();
            break;
        case '/':
            if (request.Y() == 0)
                return Response(0, -1);
            result = request.X() / request.Y();
            break;
        default:
            return Response(0, -1);
        }
        return Response(result, 0);
    }
};